//
//  UIButton + Extension.swift
//  weibo
//
//  Created by 王、小胜 on 16/7/23.
//  Copyright © 2016年 mac. All rights reserved.
//

import UIKit

extension UIButton {
    
    //便利重构
    convenience init(imageName: String , backImageName: String){
        self.init()
        
       setImage(UIImage(named:imageName), forState: UIControlState.Normal)
        setImage(UIImage(named:imageName +  "_highlight"), forState: UIControlState.Highlighted)
        setBackgroundImage(UIImage(named: backImageName), forState: UIControlState.Normal)
        setBackgroundImage(UIImage(named: backImageName + "_highlight"), forState: UIControlState.Highlighted)
        
        //根据图片大小调整尺寸
        sizeToFit()
    }
    
    //登录注册按钮构造
    
    convenience init(title:String, color:UIColor, imageName:String){
        self.init()
        
        setTitle(title, forState: .Normal)
        setTitleColor(color, forState: .Normal)
        
        //背景图
        setBackgroundImage(UIImage(named: imageName), forState: .Normal)
        
        //大小
        sizeToFit()
    }
    
    
}